﻿using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;

namespace GameStudio.Common.BootStrappers
{
    public static class BootStrappersManager
    {
        private static readonly List<IBootstrapper> _bootStrappers;

        static BootStrappersManager()
        {
            _bootStrappers = new List<IBootstrapper>();
            
            foreach(BootstrapperTask bootstrapper in BootStrapperConfigurationSection.Instance.Bootstrappers)
            {
                _bootStrappers.Add((IBootstrapper) Activator.CreateInstance(bootstrapper.Type));
            }
        } 

        public static ICollection<IBootstrapper> Bootstrappers
        {
            get
            {
                return _bootStrappers;
            }
        }

        public static void Run()
        {
            _bootStrappers.ForEach(task => task.Run());
        }
    }
}
